package com.hnit.applet.config;

import io.minio.MinioClient;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;


/**
 * @author zwj
 * @date 2022/4/21
 * @description TODO minioBean注册
 */
@Configuration
@RefreshScope
public class MinioConfig {

    @Resource
    private MinioPropertiesConfig minioPropertiesConfig;

    /**
     * 初始化minio配置
     *
     * @return MinioClient
     */
    @Bean
    @RefreshScope
    public MinioClient minioClient() {
        return MinioClient.builder().endpoint(minioPropertiesConfig.getUrl(),
                minioPropertiesConfig.getPort(),
                minioPropertiesConfig.getSecure()).credentials(minioPropertiesConfig.getAccessKey(),
                minioPropertiesConfig.getSecretKey()).build();
    }

}
